package first.endtoend.tsm.webservices;

import first.endtoend.tsm.TSMHelper;
import org.ksoap2.serialization.AttributeContainer;
import org.mbds.wolf.tsm.gp.systems.messaging2_1_0.GpFunctions;
import org.mbds.wolf.tsm.gp.systems.messaging2_1_0.IServiceEvents;
import org.mbds.wolf.tsm.gp.systems.messaging2_1_0.ksoap2.elements.OperationResult;
import org.mbds.wolf.tsm.gp.systems.messaging2_1_0.ksoap2.services.types.MobileSubscriptionIdentifierType;
import org.mbds.wolf.tsm.gp.systems.messaging2_1_0.ksoap2.services.types.SEIdentifierType;
import org.mbds.wolf.tsm.gp.systems.messaging2_1_0.ksoap2.services.types.ServiceQualifierType;
import org.mbds.wolf.tsm.gp.systems.messaging2_1_0.ksoap2.services.types.commands.SECommandType;
import org.mbds.wolf.tsm.gp.systems.messaging2_1_0.ksoap2.services.types.requests.SECommandsGenerationAndRemoteExecutionRequestType;

import java.math.BigInteger;
import java.util.ArrayList;

/**
 * Created by ncordina on 23/06/2015.
 */
public class CardContentManagement extends TSMHelper implements IServiceEvents
{
    /**
     * Class Constructor
     * Take the URL of SPTSM Server in parameter and instanciate the CallBack and the controller of Wolf library
     *
     * @param URL
     */
    public CardContentManagement(String URL)
    {
        super(URL);
    }

    @Override
    public void Starting()
    {

    }

    @Override
    public void Completed(OperationResult operationResult)
    {

    }

    /**
     *
     * @param SECommands
     * @param SEIdentifier
     * @param mobileSubscriptionIdentifierType
     * @param serviceQualifier
     * @param stopOnWarning
     */
    public synchronized void SECommandsGenerationAndRemoteExecution(ArrayList<SECommandType> SECommands,SEIdentifierType SEIdentifier, MobileSubscriptionIdentifierType mobileSubscriptionIdentifierType, ServiceQualifierType serviceQualifier, boolean stopOnWarning)
    {
        AttributeContainer container = new AttributeContainer();
        for(SECommandType command : SECommands)
        {
            container.addAttribute("SECommand",command);
        }
        SECommandsGenerationAndRemoteExecutionRequestType seCommandsGenerationAndRemoteExecutionRequestType = new SECommandsGenerationAndRemoteExecutionRequestType();
        seCommandsGenerationAndRemoteExecutionRequestType.ValidityPeriod = new BigInteger("60000");
        seCommandsGenerationAndRemoteExecutionRequestType.FunctionCallIdentifier = GpFunctions.SECommandsGenerationAndRemoteExecution.getFunction();
        //seCommandsGenerationAndRemoteExecutionRequestType.;
        //tsmController.SECommandsGenerationAndRemoteExecution();
    }

    public synchronized void SECommandsGenerationAndRemoteExecutionTest()
    {
        AttributeContainer container = new AttributeContainer();
      //  ArrayList<SECommandType> SECommands= new ArrayList<>();

      // for(SECommandType command : SECommands)
      // {
      //     container.addAttribute("SECommand",command);
      // }
        SECommandsGenerationAndRemoteExecutionRequestType seCommandsGenerationAndRemoteExecutionRequestType = new SECommandsGenerationAndRemoteExecutionRequestType();
        seCommandsGenerationAndRemoteExecutionRequestType.ValidityPeriod = new BigInteger("60000");
        seCommandsGenerationAndRemoteExecutionRequestType.FunctionCallIdentifier = GpFunctions.SECommandsGenerationAndRemoteExecution.getFunction();
        //seCommandsGenerationAndRemoteExecutionRequestType.;
        //tsmController.SECommandsGenerationAndRemoteExecution();
    }
}
